package test4_10.demo02;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class Homework21_4 {
    //使用FileWriter,向"f:/output" 输出一句话"hello world",并能过FileReader流读出这段文字

    public static void IOChar() throws IOException {
        FileWriter fw = new FileWriter("D://output.txt");
        fw.write("hello world");
        FileReader fr = new FileReader("D://output.txt");
        fw.flush();
        fw.close();

        char[] chars = new char[1024];
        int length = 0;
        while ((length = fr.read(chars))!= -1){
            System.out.println(new String(chars,0,length));
        }

        fr.close();
    }

    public static void main(String[] args) throws IOException {
        IOChar();
    }

}
